/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.EmployeeView;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "TimeCard")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TimeCard.getUnprocessTimeCards", query = "SELECT t FROM TimeCard t WHERE t.processed = 'false'"),
    @NamedQuery(name = "TimeCard.getOpenTimeCards", query = "SELECT t FROM TimeCard t WHERE t.complete = 'false'")})
public class TimeCard implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "timeCardID")
    private Integer id;
    @OneToOne
    @JoinColumn(name = "employee", referencedColumnName = "EmpID", nullable=true)
    private EmployeeView employee;
    @Column(name = "timeIn")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeIn;
    @Column(name = "lunchStart")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lunchStart;
    @Column(name = "lunchStop")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lunchStop;
    @Column(name = "timeOut")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeOut;
    @Basic(optional = false)
    @NotNull
    @Column(name = "timeCardComplete")
    private boolean complete;
    @Basic(optional = false)
    @NotNull
    @Column(name = "timeCardProcessed")
    private boolean processed;

    public TimeCard() {
    }

    public TimeCard(Integer id) {
        this.id = id;
    }

    public TimeCard(Integer id, Date timeIn, Date lunchStart, Date lunchStop, Date timeOut, boolean complete, boolean processed) {
        this.id = id;
        this.timeIn = timeIn;
        this.lunchStart = lunchStart;
        this.lunchStop = lunchStop;
        this.timeOut = timeOut;
        this.complete = complete;
        this.processed = processed;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public EmployeeView getEmployee() {
        return employee;
    }

    public void setEmployee(EmployeeView employee) {
        this.employee = employee;
    }

    public Date getTimeIn() {
        return timeIn;
    }

    public void setTimeIn(Date timeIn) {
        this.timeIn = timeIn;
    }

    public Date getLunchStart() {
        return lunchStart;
    }

    public void setLunchStart(Date lunchStart) {
        this.lunchStart = lunchStart;
    }

    public Date getLunchStop() {
        return lunchStop;
    }

    public void setLunchStop(Date lunchStop) {
        this.lunchStop = lunchStop;
    }

    public Date getTimeOut() {
        return timeOut;
    }

    public void setTimeOut(Date timeOut) {
        this.timeOut = timeOut;
    }

    public boolean isComplete() {
        return complete;
    }

    public void setComplete(boolean complete) {
        this.complete = complete;
    }

    public boolean isProcessed() {
        return processed;
    }

    public void setProcessed(boolean processed) {
        this.processed = processed;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TimeCard)) {
            return false;
        }
        TimeCard other = (TimeCard) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.TimeCard[ id=" + id + " ]";
    }
}
